package libra.sentinelRestTemplate.call.local;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("local")
public class RestTemplateLocalController {
	private static final Map info = Map.of("from", "RestTemplateLocalController");
	
	@RequestMapping("exec")
	public Object exec() {
		Map copyOf = new HashMap(info);
		copyOf.putAll( Map.of("method", "local_exec()") );
		return copyOf;
	}
	@RequestMapping("timeout")
	public Object timeout() {
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		Map copyOf = new HashMap(info);
		copyOf.putAll( Map.of("method", "local_timeout()") );
		return copyOf;
	}
	@RequestMapping("ex")
	public Object ex() {
		int i = 1/0;
		Map copyOf = new HashMap(info);
		copyOf.putAll( Map.of("method", "local_ex()") );
		return copyOf;
	}
}
